package nickthissen.iracing.datamodels;

import java.io.Serializable;

import com.google.gson.Gson;

import nickthissen.iracing.common.ForumListManager;
import nickthissen.iracing.common.ForumNames;

public class FavoriteThread implements Serializable
{
	private static final long serialVersionUID = 1849798176372892806L;

    public FavoriteThread()
    {
        if (User.currentUser != null) this.Username = User.currentUser.username;
        this.ThreadId = 0;
        this.ThreadName = "";
        this.ThreadUrl = "";
        this.ForumId = 0;
        this.ForumName = "";
    }

    public String Username;
	public int ThreadId;
	public String ThreadName;
	public String ThreadUrl;
	public int ForumId;
	public String ForumName;

    public static FavoriteThread fromThread(Thread thread, String username)
    {
        FavoriteThread fav = new FavoriteThread();
        fav.Username = username;
        fav.ThreadId = thread.Id;
        fav.ThreadName = thread.Title;
        fav.ThreadUrl = thread.Url;

        Forum f = ForumListManager.getInstance().forums.get(thread.ForumId);
        fav.ForumId = thread.ForumId;
        fav.ForumName = f.AbbreviatedName;

        return fav;
    }

    public boolean equals(FavoriteThread other)
    {
        return this.Username.equals(other.Username) && this.ThreadId == other.ThreadId && this.ForumId == other.ForumId;
    }
}
